﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Eis51.CampanyCMS.Business;
 
using Eis51.CampanyCMS.Model.Bus;
using Eis51.CampanyCMS.FrameWork;
 
using Eis51.CampanyCMS.Business.Bus;
using Eis51.CampanyCMS.Model.BaseInfoMng;
using Eis51.CampanyCMS.Business.BaseInfoMng;
using Eis51.CampanyCMS.Model;

namespace Eis51.Web.Admin.Baseinfo
{
    public partial class CompanyPage : BasePage
    {
        

       
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                ShowData();
            }
        }

        private void ShowData()
        {   
            Companyinfo c = CompanyinfoBLL.GetInstance().GetMyCompanyinfo(AppContext.CurrentAdministrator.UserName, AppContext.LCID );
            if (c != null)
            {
                UControl.CopyEntityToControl(this.Page.Form, c);
                //if (!string.IsNullOrEmpty(c.Filename))
                //{
                //   // imgShow.ImageUrl = "/Img/UpLoadFile/" + c.Filename;
                //    string file = "~/UpLoadFile/" + AppContext.CurrentAdministrator.UserName + "/Img/" + c.Filename;
                //    string strfile = "";

                //    if (Common.IsImg(file))
                //    {
                //        strfile = string.Format("<a target=_blank href='{0}' ><img src='{0}' border=0 ></a>", Page.ResolveUrl(file));
                //    }
                //    else
                //    {
                //        strfile = string.Format("<a target=_blank href='{0}' >点击下载</a>", Page.ResolveUrl(file));
                //    }

                //    lbTitle.Text = strfile;
                //}
            }
        
        }
        //private string SaveFile()
        //{
        //    string sss = UploadFile.PostedFile.FileName;
        //    string patch = Server.MapPath("~/UpLoadFile/" + AppContext.CurrentAdministrator.UserName + "/Img/");
        //    string fileName = FileListBLL.SaveFile(UploadFile, patch);
        //    return fileName;
        //}



        private bool Save()
        {

            Companyinfo c = CompanyinfoBLL.GetInstance().GetMyCompanyinfo(AppContext.CurrentAdministrator.UserName,AppContext.LCID );

            
            UControl.CopyControlToEntity(this.Page.Form, c);

            string filename = string.Empty;// SaveFile();
            if (filename != string.Empty)
            {
                c.Filename = filename;
            }
            CompanyinfoBLL.GetInstance().SubMit(c);
            return true;
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            Save();
            ShowData();
            BaseTools.ShowMessage(this.Page, "提交成功！");
        }
    }
}
